/**
 * @file printbyCol.c
 * @author your name (you@domain.com)
 * @brief 2*3数组按列打印输出
 * @version 0.1
 * @date 2022-11-22
 *
 * @copyright Copyright (c) 2022
 *
 */
#include <stdio.h>
void print_c(int *a, int n, int m)                           
{ 
          int i, j; 

          for(i = 0; i < n; i++) 
          { 
                      for(j = 0; j < m; j++) 
                            printf("%d ", *(a + i*m + j)); 

                      printf("\n"); 
          } 
}
int main()
{
    short int a[2][3] =
        {{1, 2, 3}, {4, 5, 6}};
    short int i, j, *p;
    p = &a[0][0];//p = a;
    for (i = 0; i < 2; i++)
    {
        for (j = 0; j < 3; j++)
            printf("a[%d][%d]= %d ",i,j, *(p + i * 3 + j));
        printf("\n");
    }
    //设计函数，按列输出
    printbyCol(&a[0][0]);
    //print_c(*a,2,3);
    return 0;
}
//函数的实现
void printbyCol(int arrP[][3])
{
    int i,j,*p;
    //p = arrP;
    for(j=0;j<3;j++)
    {
        for(i=0;i<2;i++)
        {
            //a[0][0],a[1][0]
            printf("a[%d][%d]=%d ",i,j,*(arrP+3*i+j));
        }
        printf("\n");
    }
}